/*
 * @Author: wangtao
 * @Date: 2020-06-28 15:43:56
 * @LastEditors: 汪滔
 * @LastEditTime: 2021-08-10 18:20:24
 * @Description: 图片预览
 */

import React, { Component } from 'react';
import {
  StyleSheet,
  View,
  Text,
  Image,
  ScrollView,
  TouchableOpacity,
  NativeModules,
  Modal,
} from 'react-native';
import {
  mainBgColorLightGray,
  mainBgColorWhite,
  priceColor,
  fontColorBlack,
  fontColorLightGray,
  fontColorCoffee,
  screenWidth,
  px2dp,
  fontColorSecDeepGray,
  screenHeight,
} from '@/styles';
import { Button, msg, _, } from '@/common';

export default class CarImgPreview extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {
    const { goodsId } = this.props;
  }

  render() {
    const { previewUrl, onChangeModal } = this.props;
    console.log('🚀🚀🚀wimi======>>>previewUrl', previewUrl);
    return (
      <Modal
        animationType='fade'
        transparent
        visible
        onRequestClose={() => {
          onChangeModal({ type: 'previewModalShow', val: false, previewUrl: '' });
          // msg.emit('router: back');
        }}
        onShow={() => {}}
      >
        <TouchableOpacity
          style={styles.mask}
          onPress={() => {
            onChangeModal({
              type: 'previewModalShow',
              val: false,
              previewUrl: '',
            });
          }}
        />
        <Image
          source={{ uri: previewUrl }}
          style={{ width: screenWidth, height: 400, marginTop: screenHeight / 2 - 200 }}
          resizeMode='contain'
        />
      </Modal>
    );
  }
}
const styles = StyleSheet.create({
  container: {
    width: screenWidth,
    height: screenHeight,
    position: 'absolute',
    left: 0,
    top: 0,
    justifyContent: 'center',
    alignItems: 'center',
    zIndex: -1
  },

  mask: {
    width: screenWidth,
    height: screenHeight,
    backgroundColor: 'rgba(0,0,0,0.2)',
    position: 'absolute',
    left: 0,
    top: 0,
  },
});
